import { pget, ppostJson, post } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'

// 采购计划分页
export function getTableList(query?: any) {
	return pget(`${modalApi.purchase}/shopec-purchase-plan/plan/page`, query)
}

// 采购计划详情分页
export function getDetailPlanList(query?: any) {
	return pget(`${modalApi.purchase}/shopec-purchase-plan/plan/list`, query)
}

// 采购计划无分页
export function getAllList(query?: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-plan/plan/availableList`,
		query,
	)
}

// 采购计划明细分页
export function getTableListDetail(data: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-planitem/planitem/list`,
		data,
	)
}

// 新增采购计划
export function addPlan(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-plan/plan/save`,
		data,
	)
}
/** 采购计划保存 */
export function planSaveTemporary(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-plan/plan/saveTemporary`,
		data,
	);
}

// 修改采购计划
export function editPlan(id: string, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-plan/plan/update/${id}`,
		data,
	)
}

// 删除采购计划
export function deletePlan(data: { ids: string }) {
	return post(`${modalApi.purchase}/shopec-purchase-plan/plan/remove`, data)
}

// 查看采购计划
export function viewPlan(planId: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-plan/plan/detail/${planId}`,
	)
}

// 复制采购计划
export function copyPlan(id: string) {
	return pget(`${modalApi.purchase}/shopec-purchase-plan/plan/copy/${id}`)
}

/** 保存采购计划导入数据 */
export function planImport(query?: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-plan/plan/import/${query.batch}`,
	)
}

// 工作流接口
/** 流程新增 */
export function planProcessAdd(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-plan/plan/submitFlow`,
		data,
	)
}
// 采购计划审核
export function planAuditFlow(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-plan/plan/auditFlow`,
		data,
	)
}
// 作废采购计划重新发起审核
export function planRelaunchFlow(id: any, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-plan/plan/relaunchFlow/${id}`,
		data,
	)
}
